package org.javaz.ports;

import java.util.Comparator;

/**
 */
public class RequiredByComparator implements Comparator
{

	public int compare(Object o1, Object o2)
	{
		if (o1 == null || !(o1 instanceof PortVersionInfo) || o2 == null || !(o2 instanceof PortVersionInfo))
		{
			return 0;
		}
		else
		{
			int x1 = ((PortVersionInfo) o1).getRequiredBy().size();
			int x2 = ((PortVersionInfo) o2).getRequiredBy().size();
			if (x1 < x2)
			{
				return 1;
			}
			if (x1 > x2)
			{
				return -1;
			}
		}
		return 0;
	}
}
